package test_315;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张杰
 * Date: 2022-03-15
 * Time: 10:51
 */
class OuterClass2 {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    //静态内部类:
    static class InnerClass {
        public int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6;

        public void test() {
            System.out.println("InnerClass::test()");
        }
    }
}
class Test {
    public void test() {
        System.out.println("test()haha");

    }}
public class TestDemo2 {
    public static void main(String[] args) {
        //静态内部类的方法
        OuterClass2.InnerClass innerClass = new OuterClass2.InnerClass();
        innerClass.test();

        //匿名内部类
        new Test(){
            @Override
            public void test() {
                System.out.println("重写的test!");
            }
        }.test();//调用test方法
    }
}
